# -*- coding: utf-8 -*-

from odoo import models, fields, api,_
from odoo.exceptions import ValidationError


class HrEMPLOYEE(models.Model):
    _inherit = 'hr.employee'

    payment_balance=fields.Float(compute='compute_payment_balance')

    def compute_payment_balance(self):
        for r in self:
            ids=self.env['expense.advance.payment'].search([('employee_id','=',r.id),('state','=','done'),('reconciled','!=',True)])
            if ids:
                r.payment_balance=sum(i.advance_payment_reminding for i in ids)
            else:
                r.payment_balance=0
